#!/usr/bin/enr/python3
# -*- coding: utf-8 -*-
# -------------------------------
# @Author : hurong
# @File : 01for_while_demo.py
# @Time : 2023/6/17 22:33
# -------------------------------

# # 计算1~100求和；使用分支结构实现1~100之间的偶数求和
# # 不使用分支结构实现1~100之间的偶数求和
# sum = 0
# # for i in range(1, 101):
# #     #print(i)
# # 对i取余，如果余数为0，则证明i为偶数求和
# #     if i%2 == 0:
# #         sum = sum + i
# #         print(sum)
# for i in range(2, 101, 2):
#     sum = sum + i
#     print(sum)

# # while循环实例
# # 题目：猜数字游戏；1）计算机出一个1~100之间的随机数由人来猜；
# # 2）计算机根据人猜的数字分别给出提示大一点/小一点/猜对了
#
# # 先给出随机数
# import random
#
# computer_num = random.randint(1, 100)
# # print("computer_num", {computer_num})
#
# while True:
#     people_num = int(input("请输入数字:"))
#     if people_num > computer_num:
#         print("小一点")
#     elif people_num < computer_num:
#         print("大一点")
#     else:
#         print("猜对了")
#         break

# 题目三：
# 不使用分支结构实现1~100之间的奇数求和
# 使用while语句实现1~100之间的奇数求和
sum = 0
# for i in range(1, 101, 2):
#     sum = sum + i
#     print(sum)
i = 1
while i < 100:
    if i % 2 == 1:
        sum = sum + i
        # print(sum)
    i = i + 1
print(sum)






